home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 22 / Cream of the Crop 22.iso / os2 / os2ntp11.zip / os2_ntpd.man < prev    next >
Text File  |  1996-11-22  |  26KB  |  467 lines

  1.                            User's Guide to OS2_NTPD,
  2.                    Network Time Protocol Client for OS/2 Warp
  3.                          Release 1.1, November 23, 1996
  4.  
  5.                                       by
  6.                     Bruce M. Penrod (bpenrod@truetime.com),
  7.                                  TrueTime Inc.
  8.  
  9.  
  10. I.  INTRODUCTION
  11.  
  12. OS2_NTPD is a 32-bit, multi-threaded, text mode, NTP client application that
  13. runs in a Presentation Manager text window.  It requires either OS/2 2.1 with
  14. TCP/IP version 2.0 or OS/2 version 3.0 or 4.0 (aka WARP or WARP Connect) to
  15. operate. It may reside in either an HPFS or FAT partition.  Three files must be
  16. present in the same directory:
  17.  
  18. 1)  os2_ntpd.exe       (the main program)
  19.  
  20. 2)  portio.dll         (a dynamic link library which gives os2_ntpd.exe access
  21.                         to the I/O ports and thereby the real time clock chip.
  22.                         It must reside in a directory included in the LIBPATH=
  23.                         statement of the config.sys or in the directory from
  24.                         which os2_ntpd.exe is executed. )
  25.  
  26. 3)  cfg_data           (data file containing the list of NTP servers to poll
  27.                         and the initial polling interval--optional if provided
  28.                         from command line in single server mode)
  29.  
  30. In addition, tcp32dll.dll and so32dll.dll must be present on the system in a
  31. directory which is included in the LIBPATH= statement in the config.sys.
  32.  
  33. After OS2_NTPD has been executed the first time, these additional files will be
  34. created in the same directory:
  35.  
  36. 1)  rtc_type           (data file containing the type of real time clock chip
  37.                         present on the system board--there are two different
  38.                         types,  unfortunately, indicated by a value of either 0
  39.                         or 500 in this file)
  40.  
  41. 2)  drift              (data file containing the NTP timestamp rounded to
  42.                         whole seconds of the last correction that was made to
  43.                         the real time clock followed by the fractional
  44.                         frequency offset of the real time clock timebase,
  45.                         positive means that the system clock is fast.  It may
  46.                         take several hours for this file to appear the first
  47.                         time)
  48.  
  49. 3)  suspects           (when debugging is enabled, data file containing server
  50.                        reply packets which differ from the client ensemble
  51.                        clock by more than 250 ms. This file may grow without
  52.                        bound, so it should be checked and deleted from time to
  53.                        time.  The format of these packets is identical to that
  54.                        which is displayed on the user interface screen)
  55.  
  56. In addition, if logfile is turned on, then a log file with name equal to the
  57. NTP seconds (seconds since Jan 1, 1900) in hexadecimal at the time the logfile
  58. was first opened and extension equal to "log"  is created,  for example a
  59. typical logfile name might be:
  60.  
  61. b5afc01a.log
  62.  
  63. This logfile contains a list of the NTP servers which were present in the
  64. cfg_data file when the program was first executed, followed by an NTP timestamp
  65. column which is followed by three columns for each server of statistics on the
  66. time received from that server.  These statistics are the current raw
  67. measurement of that (server - client), the mean of these raw measurements taken
  68. over approximately twenty samples, and the standard deviation of these raw
  69. measurements.
  70.  
  71. After the statistics for each of the servers come columns which contain the
  72. ensemble statistics.  The first ensemble statistic is the ensemble, or weighted
  73. average of all of the (server - client) raw measurements.  This is followed by
  74. the standard deviation of the ensemble.  Next is the phase locked loop filter
  75. output value, followed by the fractional frequency offset of the local clock
  76. timebase, followed finally by the actual clock correction in seconds applied to
  77. the system clock.
  78.  
  79.  
  80. II.  INSTALLATION
  81.  
  82. *********************************IMPORTANT************************************
  83. If you are upgrading from version 1.0, you MUST replace both the os2_ntpd.exe
  84. and the portio.dll files.  The version of portio.dll included with version 1.0
  85. IS NOT COMPATIBLE with version 1.1.
  86. ******************************************************************************
  87.  
  88. Installation is simple, just create a directory and unzip the distribution file,
  89. os2ntp11.zip into it.  In addition, check the system config.sys file on the
  90. OS/2 boot partition and make sure that the line:
  91.  
  92. IOPL=YES
  93.  
  94. is present in it.  If it is not, or is set equal to NO, change it.  OS2_NTPD
  95. MUST HAVE ACCESS to I/O ports in order to read and set the system real
  96. time clock chip.  As an alternative to providing broad IOPL access, specific
  97. access to certain executables is possible, for example:
  98.  
  99. IOPL=os2_ntpd.exe
  100.  
  101. is also OK.
  102.  
  103. Since NTP is based on UTC time, it will be necessary to set the environment
  104. variable TZ so that the local offset to UTC may be maintained when OS2_NTPD is
  105. operating on the system clock.  A statement like this must appear somewhere in
  106. your config.sys:
  107.  
  108. SET TZ=PST+8PDT
  109.  
  110. This example is appropriate for users on the west coast of the USA who
  111. operate with Pacific Standard Time (PST) or Pacific Daylight Time (PDT) and
  112. are 8 hours behind UTC when PST is in effect.  If daylight time is not used,
  113. leave off the last three characters:
  114.  
  115. SET TZ=PST+8
  116.  
  117. To set TZ for more complicated situations, use the following format:
  118.  
  119. ┌──────────────────────────────────────────────────────────────────────────────┐
  120. │                                                                              │
  121. │ >>──SET──TZ──=──SSS──┬──────────────────────────────┬──────────────────────> │
  122. │                      └─┬───┬──h──┬────────────────┬─┘                        │
  123. │                        ├─+─┤     └─:──m──┬──────┬─┘                          │
  124. │                        └─┴─┘             └─:──s─┘                            │
  125. │                                                                              │
  126. │ >──┬─────────────────────────────────────────┬────────────────────────────>< │
  127. │    └─DDD──┬────────────────────────────────┬─┘                               │
  128. │           └─,sm,sw,sd,st,em,ew,ed,et,shift─┘                                 │
  129. │                                                                              │
  130. └──────────────────────────────────────────────────────────────────────────────┘
  131.  
  132. The values for the TZ variable are defined below.  The default values given are
  133. for the built-in "C" locale defined by the ANSI C standard.
  134.  
  135. ┌──────────────────────────────────────────────────────────────────────────────┐
  136. │ Table 1. TZ Environment Variable Parameters                                  │
  137. ├──────────────┬─────────────────────────────────────────────┬─────────────────┤
  138. │ VARIABLE     │ DESCRIPTION                                 │ DEFAULT VALUE   │
  139. ├──────────────┼─────────────────────────────────────────────┼─────────────────┤
  140. │ SSS          │ Standard-timezone identifier.  It must be   │ EST             │
  141. │              │ three characters, must begin with a letter, │                 │
  142. │              │ and can contain spaces.                     │                 │
  143. ├──────────────┼─────────────────────────────────────────────┼─────────────────┤
  144. │ h, m, s      │ The variable h specifies the difference (in │ 5               │
  145. │              │ hours) between the standard time zone and   │                 │
  146. │              │ coordinated universal time (CUT), formerly  │                 │
  147. │              │ Greenwich mean time (GMT).  You can         │                 │
  148. │              │ optionally use m to specify minutes after   │                 │
  149. │              │ the hour, and s to specify seconds after    │                 │
  150. │              │ the minute.  A positive number denotes time │                 │
  151. │              │ zones west of the Greenwich meridian; a     │                 │
  152. │              │ negative number denotes time zones east of  │                 │
  153. │              │ the Greenwich meridian.  The number must be │                 │
  154. │              │ an integer value.                           │                 │
  155. ├──────────────┼─────────────────────────────────────────────┼─────────────────┤
  156. │ DDD          │ Daylight saving time (DST) zone identifier. │ EDT             │
  157. │              │ It must be three characters, must begin     │                 │
  158. │              │ with a letter, and can contain spaces.      │                 │
  159. ├──────────────┼─────────────────────────────────────────────┼─────────────────┤
  160. │ sm           │ Starting month (1 to 12) of DST.            │ 4               │
  161. ├──────────────┼─────────────────────────────────────────────┼─────────────────┤
  162. │ sw           │ Starting week (-4 to 4) of DST.  Use nega-  │ 1               │
  163. │              │ tive numbers to count back from the last    │                 │
  164. │              │ week of the month (-1) and positive numbers │                 │
  165. │              │ to count from the first week (1).           │                 │
  166. ├──────────────┼─────────────────────────────────────────────┼─────────────────┤
  167. │ sd           │ Starting day of DST.                        │ 0               │
  168. │              │ 0 to 6 if sw != 0                           │                 │
  169. │              │ 1 to 31 if sw = 0                           │                 │
  170. ├──────────────┼─────────────────────────────────────────────┼─────────────────┤
  171. │ st           │ Starting time (in seconds) of DST.          │ 3600            │
  172. ├──────────────┼─────────────────────────────────────────────┼─────────────────┤
  173. │ em           │ Ending month (1 to 12) of DST.              │ 10              │
  174. ├──────────────┼─────────────────────────────────────────────┼─────────────────┤
  175. │ ew           │ Ending week (-4 to 4) of DST.  Use negative │ -1              │
  176. │              │ numbers to count back from the last week of │                 │
  177. │              │ the month (-1) and positive numbers to      │                 │
  178. │              │ count from the first week (1).              │                 │
  179. ├──────────────┼─────────────────────────────────────────────┼─────────────────┤
  180. │ ed           │ Ending day of DST.                          │ 0               │
  181. │              │ 0 to 6 if ew != 0                           │                 │
  182. │              │ 1 to 31 if ew = 0                           │                 │
  183. ├──────────────┼─────────────────────────────────────────────┼─────────────────┤
  184. │ et           │ Ending time of DST (in seconds).            │ 7200            │
  185. ├──────────────┼─────────────────────────────────────────────┼─────────────────┤
  186. │ shift        │ Amount of time change (in seconds).         │ 3600            │
  187. └──────────────┴─────────────────────────────────────────────┴─────────────────┘
  188.  
  189. For example:
  190.  
  191.    SET TZ=CST6CDT
  192.  
  193. sets the standard time zone to CST, the daylight saving time zone to CDT, and
  194. sets a difference of 6 hours between CST and CUT. It does not set any values for
  195. the start and end date of daylight saving time or the time shifted.
  196.  
  197. When TZ is not present, the default is EST5EDT, the "C" locale value. When only
  198. the standard time zone is specified, the default value of n (difference in hours
  199. from GMT) is 0 instead of 5.
  200.  
  201. If you give values for any of sm, sw, sd, st, em, ew, ed, et, or shift, you must
  202. give values for all of them. Otherwise the entire statement is considered not
  203. valid, and the time zone information is not changed.
  204.  
  205.  
  206.  
  207. About the Real Time Clock
  208.  
  209. For system timekeeping and task scheduling, OS/2 uses the Motorola MC146818 RTC
  210. chip which IBM originally designed into the AT machines.  OS/2 sets the chip up
  211. to generate an interrupt 32 times a second, or every 31.25 ms.  OS2_NTPD
  212. performs system clock corrections by actually resetting the RTC chip at the
  213. appropriate time so as to step the time in increments as small as one tick, or
  214. 31.25 ms, forward or backward.  This works beautifully for motherboards which
  215. emulate the Motorola RTC chip faithfully.  However, some motherboards
  216. incorrectly emulated the chip and this causes hiccups in the time adjustments
  217. performed by OS2_NTPD on occasion.
  218.  
  219. The difference is in how the chips behave after divisor reset, the method of
  220. timestepping used by OS2_NTPD.  Truly compatible implementations update the next
  221. second 500 ms after divisor reset.  The other implementations I have seen
  222. update it immediately following divisor reset.  This causes problems when a
  223. small, single tick correction is being made and the actual time that it is
  224. performed slips by a tick due to pre-emption, etc.  This slip causes a whole
  225. second error to occur instead of one tick.  I have not successfully eliminated
  226. these occurrences yet, however they are rare.  They seem to be worst on heavily
  227. loaded systems and systems running dial-up serial modems using PPP, which runs
  228. at a very high priority.
  229.  
  230. Following the initial execution of OS2_NTPD, the data file rtc_type will hold
  231. the results of its check for the type of RTC chip in your system.  If the value
  232. stored in rtc_type is zero, then your RTC is 100% compatible and you should
  233. have no problems such as I have described.  If the value is 500, then you
  234. should expect to experience the one second hiccups from time to time if your
  235. system is underpowered or heavily loaded or are accessing the Internet via dial-
  236. up modem.
  237.  
  238.  
  239. III.  OPERATION
  240.  
  241. OS2_NTPD may be executed in one of two ways:
  242.  
  243. 1)  From the command line using a single server, with these arguments as so:
  244.  
  245. os2_ntpd.exe [ntp server(name or dotted decimal)
  246.               initial polling interval (integer seconds)
  247.               number of requests to send (integer)]
  248.  
  249. where:  "ntp server" is the IP address of the NTP server, i.e.
  250.          tick.usno.navy.mil or 206.54.0.21
  251.  
  252.         "initial polling interval" is the number of seconds between requests
  253.          to the server.  It should be a power of two, such as 2, 4, 8, 16 etc.
  254.  
  255.         "number of requests to send" is how many times to request time from
  256.          the server, if 0 is entered then requests will be sent indefinitely
  257.  
  258. All of these arguments must be present on the command line, separated by spaces.
  259. There are no defaults.
  260.  
  261. 2)  From the command line with no arguments.  When executed this way, OS2_NTPD
  262. looks for the data file cfg_data in the current directory.  If it is not found,
  263. then an error message is displayed in the window.  If it is found, and its
  264. format is correct, then OS2_NTPD will display the contents of the file in the
  265. window.  A sample cfg_data file:
  266.  
  267. cfg_data
  268. poll interval = 16
  269. tick.usno.navy.mil
  270. tock.usno.navy.mil
  271. time.nist.gov
  272. 206.54.0.21
  273.  
  274. Each line must appear exactly as shown, terminated by a CR and LF.  Up to 22
  275. NTP servers may be listed following the poll_interval line.  A single CR and LF
  276. should follow the last server name.
  277.  
  278. Of course, a Workplace Shell program object may be created allowing execution
  279. via mouse clicks, and a copy of the program object could be dragged to the
  280. Startup Folder to allow automatic invocation following each boot up.
  281.  
  282.  
  283. The OS2_NTPD User Interface
  284.  
  285. After reading the cfg_data file and displaying the server list, the
  286. program will display an interface screen.  This screen is a standard 25 line by
  287. 80 character text mode window, divided into three regions.  The top
  288. region consists of thirteen lines which display decoded packets, and the list
  289. of NTP servers.  The next region consists of three lines displaying output
  290. status information such as timeouts, reply packets which are indicating an
  291. alarm state, ensemble statistics, etc.  The bottom five lines make up a
  292. function key driven menu with up to twelve selections, not all of which are in
  293. use at this time.  The current active function keys are:
  294.  
  295. F1   Show Next Pkt -- Pressing this key will display the decoded packet
  296.                       received from the first server from which a reply was
  297.                       received in the current polling interval.  Pressing it
  298.                       again will display the next one and so on. Underneath the
  299.                       raw packet information are displayed the server specific
  300.                       timing statistics:  the current server - client offset
  301.                       measurement in seconds, the standard deviation of those
  302.                       measurements, and the maximum and minimum measurements.
  303.  
  304. F2   Show Prev Pkt -- Pressing this key will display the decoded packet
  305.                       received from the last server from which a reply was
  306.                       received in the current polling interval.  Pressing it
  307.                       again will display the previous one and so on.
  308.  
  309. F6   Quick Sync    -- Pressing this key will enable an instantaneous "jam sync"
  310.                       of the system clock based on the next ensemble of replies
  311.                       received from the active servers.  The default behavior
  312.                       if this key is not pressed is to propagate the ensembled
  313.                       replies through a phase locked loop filter which will
  314.                       slowly bring the system clock in line with the NTP
  315.                       servers.  The Quick Sync function is similar to NTPDATE
  316.                       in that it is used to establish a starting
  317.                       synchronization which is then refined based on further
  318.                       averaging of NTP server replies and gradual corrections.
  319.  
  320. F7  Show Peers     -- Pressing this key will display a list of the peers which
  321.                       were active during the current polling interval.
  322.  
  323. F10  Enable Debug  -- Pressing this key will enable logging of suspect reply
  324.                       packets to the file "suspects".  This logfile will be
  325.                       opened for appending and closed after each polling
  326.                       interval.   Pressing the key again will suspend logging
  327.                       to this file.
  328.  
  329. F11  Open LogFile  -- Pressing this key the first time will open a logfile that
  330.                       is named with the current ntp second.  This logfile will
  331.                       be opened for appending and closed after each polling
  332.                       interval and contains the reduced timing data from each
  333.                       of the servers in the cfg_data file, as well as ensemble
  334.                       statistics.    Once the logfile is open, pressing the key
  335.                       again will close the file permanently.
  336.  
  337. F12  About         -- Pressing this key will display information about this
  338.                       program.
  339.  
  340.  
  341. IV.  THEORY OF OPERATION
  342.  
  343. Interested users should consider downloading the RFCs relating to network
  344. timing written by David Mills of the University of Delaware.  These cover in
  345. gory detail the inner workings of the NTP.  Mills also maintains a website,
  346. http: //www.eecis.udel.edu/~ntp/ which is a vast repository of NTP related lore
  347. and entertainment.  OS2_NTPD operates based on version 3.0 of the NTP as
  348. described in RFC 1305.  Here I will only mention that the cornerstone of the
  349. NTP is server diversity.  The benefits of statistical ensembling and clustering
  350. are not available if only one server is being polled. OS2_NTPD allows up to 22
  351. servers to be configured for this reason.
  352.  
  353. OS2_NTPD maintains stability measurements on each server being used to set the
  354. client clock.  These stability measures are used to calculate weighting of the
  355. individual server's contribution to the overall ensemble.  Noisy servers
  356. receive less weighting, quiet ones more.  Further, due to the ordering of
  357. the procedures, when a measurement comes in from a server, its weight is
  358. updated first,  then the measurement is added into the ensemble based on
  359. the new weight.  This provides a measure of immunity from bad server replies
  360. since they are de-weighted prior to being used.
  361.  
  362. Once an ensemble measurement has been synthesized, it is passed to the phase
  363. locked loop which controls the system clock.  The phase locked loop implements
  364. averaging of the NTP server reply data across time as opposed to the ensembling
  365. algorithm which implements averaging across multiple servers.  Initially the
  366. PLL operates fairly quickly and updates the RTC at the rate specified by the
  367. initial polling interval parameter provided in the cfg_data file or from the
  368. command line.  Once the client clock has been pulled within a tick (31. 25 ms)
  369. then the polling interval is lengthened by a factor of two.  Each time the
  370. ensemble measurement is within a tick, the polling interval is again lengthened
  371. until it reaches 256 seconds, beyond which it does not extend. After the
  372. polling interval has reached 256 seconds, PLL averaging is further extended by
  373. modifying the coefficients in the digital loop filter.  These are allowed to
  374. extend until the PLL equivalent averaging time has reached 13401 seconds.
  375.  
  376. The main reason for setting the averaging time so long is to allow an accurate
  377. measurement of the frequency offset of the client clock timebase.  This
  378. frequency offset has been referred to as "skew" in the Mills literature.
  379. Unfortunately, the file created by the Unix versions of NTP containing
  380. this skew term is called NTPDRIFT.  Drift has actually been defined by the
  381. global time and frequency community to mean the change in frequency of an
  382. oscillator as a function of time, not its change in phase.  So as not to
  383. confuse those who have dealt with the various ports of Mills' NTP client
  384. daemons, I have retained the " drift" naming convention for the file which
  385. holds the fractional frequency offset of the client clock timebase.
  386.  
  387. OS2_NTPD uses this "drift" to extrapolate the behavior of the client clock when
  388. no servers are available, so that corrections may continue to be made to the
  389. clock to compensate for its assumed constant frequency error.  In addition,
  390. after a power outage,  OS2_NTPD checks the timestamp in the "drift" file to
  391. determine the length of the outage and will apply a correction based on the
  392. outage duration and the fractional frequency offset which was stored in the
  393. "drift" file.  This approach is not fool proof, since corrections made
  394. manually or by other programs during the outage of OS2_NTPD operation will not
  395. be known to OS2_NTPD.  Also, the frequency of the crystal oscillator inside of
  396. the PC will be different when the power is applied as compared to when it is
  397. not since the temperature inside the PC is dependent upon this.
  398.  
  399.  
  400. Current Known Deficiencies in this version of the OS2_NTPD Client NTP:
  401.  
  402. 1) The Leap Indicator bits are currently used only to detect server alarm
  403. condition.  No attempt is made to transparently implement any leap second event
  404. at the correct time.  This may be fixed in the future when more servers
  405. properly indicate leap second events in these bits, which is not the case now!
  406.  
  407. 2) The movement of time from Standard to Daylight and vice versa currently
  408. propagates through the PLL loop filter and so takes a slow journey--maybe an
  409. hour or so to get there.  Will fix this eventually, but recommend that you do
  410. not run your workstations on anything but Standard time, be it local or UTC.
  411.  
  412. 2) No preference is currently given to servers based on their operating NTP
  413. stratum level or root dispersion.
  414.  
  415.  
  416. Bugfixes included in version 1.1 of OS2_NTPD:
  417.  
  418. 1)    Some versions of OS/2 Warp Connect with various FixPacks at about 17 were
  419. unable to run version 1.0 of the program, aborting with a "Stack Overflow"
  420. message immediately following start-up.  I changed the compiler from Borland
  421. 1.5 to IBM VAC++ 3.0, increased the stacksize in the threads and rearranged the
  422. operation of the threads to eliminate the possibility of clean-up not being
  423. performed. These systems are now able to run the program but there are still
  424. some questions concerning memory leakage and system lock-ups on those same
  425. systems.  I will be welcoming any feedback as to whether I have fixed those
  426. problems!
  427.  
  428. 2)    Borland did not do a very good job on the TZ environment variable in
  429. their tzset() routine, choosing to have it handle only North American time zone
  430. changes properly.  Since changing to the IBM compiler for this version,
  431. OS2_NTPD fully supports the TZ environment variable as described in this manual
  432. so that both standard time and daylight time may work anywhere in the world if
  433. the TZ variable is set up properly.
  434.  
  435. 3)    The REF ID field of the NTP packet was not being decoded properly with
  436. servers operating at Stratum 2 or higher in version 1.0 of OS2_NTPD.  It should
  437. have shown the IP address of the server to which that server is peered rather
  438. than the ascii clock type code like GPS or ACTS as would be done for Stratum 1
  439. servers.
  440.  
  441. 4)    Some users with non-compatible RTC implementations have experienced the
  442. one second hiccups in the RTC correction process that is described in this
  443. manual.  In version 1.1, I have managed to reduce them to an acceptable
  444. level on my machines by giving up some of the resolution of the correction.
  445. What this amounts to is that when I detect the RTC type, if it is a non-
  446. compatible one, I perform two tick clock adjustments instead of single tick
  447. adjustments.  Due to the subleties of the adjustment process, this still allows
  448. me to maintain an accuracy of about one tick, or 31.25 ms but greatly reduces
  449. the frequency of the hiccups.
  450.  
  451. 5)    Fixed a potential string overflow problem when extremely large offsets
  452. between the local clock and a server were being displayed.
  453.  
  454.  
  455.  
  456.  
  457.  
  458. DISCLAIMER!!!
  459.  
  460. The author makes no claims concerning suitability of this program for any use.
  461. OS2_NTPD is offered for your use "as is", with no expressed or implied
  462. warranties or guarantees of any kind.  The author will assume no liability for
  463. damages either from the direct use of this product or as a consequence of the
  464. use of this product.
  465.  
  466.  
  467.